export default defineEventHandler(async (event) => {
  const id = getRouterParam(event, 'id')
  
  if (!id) {
    throw createError({
      statusCode: 400,
      statusMessage: '用户ID不能为空'
    })
  }
  
  // 模拟用户数据
  const users = [
    {
      id: 1,
      name: '张三',
      email: 'zhangsan@example.com',
      avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=1',
      role: 'admin',
      status: 'active',
      phone: '13800138001',
      address: '北京市朝阳区',
      bio: '资深前端开发工程师，专注于Vue.js和Nuxt.js开发',
      createdAt: '2024-01-15T10:30:00Z',
      lastLogin: '2024-03-15T08:30:00Z'
    },
    {
      id: 2,
      name: '李四',
      email: 'lisi@example.com',
      avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=2',
      role: 'user',
      status: 'active',
      phone: '13800138002',
      address: '上海市浦东新区',
      bio: 'UI/UX设计师，热爱创造美好的用户体验',
      createdAt: '2024-01-20T14:20:00Z',
      lastLogin: '2024-03-14T16:20:00Z'
    },
    {
      id: 3,
      name: '王五',
      email: 'wangwu@example.com',
      avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=3',
      role: 'user',
      status: 'inactive',
      phone: '13800138003',
      address: '广州市天河区',
      bio: '后端开发工程师，擅长Node.js和数据库设计',
      createdAt: '2024-02-01T09:15:00Z',
      lastLogin: '2024-03-10T12:15:00Z'
    }
  ]

  const user = users.find(u => u.id === parseInt(id))
  
  if (!user) {
    throw createError({
      statusCode: 404,
      statusMessage: '用户不存在'
    })
  }

  // 模拟延迟
  await new Promise(resolve => setTimeout(resolve, 150))

  return {
    code: 200,
    message: '获取用户详情成功',
    data: user
  }
}) 